package com.capacitydorm.server.dao;

import com.capacitydorm.server.domain.Dorm;
import com.capacitydorm.server.domain.Floor;
import org.apache.ibatis.annotations.*;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@org.apache.ibatis.annotations.Mapper
public interface FloorMapper extends Mapper<Floor> {
    @Select("select  *  from   c_floor where  id=#{id}")
    @Results(id="floor",value = {
            @Result(property = "id", column = "id"),
            @Result(property = "number", column = "number"),
            @Result(property = "towerId", column = "tower_id"),
            @Result(property = "tower", one = @One(select = "com.capacitydorm.server.dao.TowerMapper.selectByPrimaryKey"), column = "tower_id"),
    })
    Floor findById(@Param("id") Integer id);

    @Select("select  *  from   c_floor where  tower_id=#{tower_id}")
    @ResultMap("floor")
    List<Floor> findByTowerId(@Param("tower_id") Integer tower_id);
}
